package com.filldream.fastboot.web.controller.pc;

import com.filldream.fastboot.base.entity.SysLog;
import com.filldream.fastboot.base.request.IdSTO;
import com.filldream.fastboot.base.request.pc.sysLog.SysLogPageSTO;
import com.filldream.fastboot.common.annotation.Log;
import com.filldream.fastboot.common.annotation.RolePermissions;
import com.filldream.fastboot.common.entity.B;
import com.filldream.fastboot.common.entity.P;
import com.filldream.fastboot.common.entity.R;
import com.filldream.fastboot.core.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "PC-系统日志管理")
@RestController
@RequestMapping("/pc/sysLog")
public class PcSysLogController {

    @Autowired
    private SysLogService sysLogService;

    @ApiOperation(value = "日志列表")
    @GetMapping(value = "/page")
    @RolePermissions("sysLog:page")
    public P<SysLog> page(SysLogPageSTO sysLogPageSTO) {
        return sysLogService.page(sysLogPageSTO);
    }

    @Log(value = "清空日志")
    @ApiOperation(value = "清空日志",notes = "传入linkId")
    @PostMapping(value = "/clear")
    @RolePermissions("sysLog:clear")
    public B clear() {
        return sysLogService.clear(null);
    }

    @ApiOperation(value = "查看日志详情",notes = "传入日志ID")
    @GetMapping(value = "/get")
    @RolePermissions("sysLog:get")
    public R<SysLog> get(IdSTO idSTO) {
        return R.successd(sysLogService.getById(idSTO.getId()));
    }


}
